#ifndef SRC_SORTER_H_
#define SRC_SORTER_H_

template <typename T> class Sorter { // template class
public:
	Sorter(){memset(&array,0,sizeof(array)); len = 0 ;}
	~Sorter();
    bool add(T ele)
    {
    	if( len < 60 ) array[len++] = ele; else return false;
    	return true;
    }
    void sort()
    {
    	for(int p = 0;p < len -1;p++)             // Loop for Pass
    	{


    		for(int j = 0;j < len-1;j++)
    		{
    			if(array[j] > array[j+1])
    			{
    				int temp = array[j];                      // Interchange Values
    				array[j] = array[j+1];
    				array[j+1] = temp;
    			}
    		}
    	}
    }



    void getArray(T*& ptr = 0)
    {

    	if ( 0 == ptr )
    	{
    		ptr = new T[60];
    	}
    	memcpy(ptr,array,sizeof(array));
    }
private:


	T array[60];
	int len;

};


template <> class Sorter<short>
{
public :
	Sorter() {;}
	~Sorter() {;}
    bool add(short ele) { return false;}
    void sort() { throw int(0);}
    void getArray(short*& ptr)
    {
    	 (ptr = new short());
    }
};
#endif /* SRC_SORTER_H_ */
